CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/pages/store/[[...page]].tsx
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { Layout } from "antd";
7
import Header from "components/landing/header";
8
import Footer from "components/landing/footer";
9
import Head from "components/landing/head";
10
import Store from "components/store";
11
import { StorePages } from "components/store/types";
12
import { Customize } from "lib/customize";
13
import withCustomize from "lib/with-customize";
14
import { capitalize } from "@cocalc/util/misc";
15
import Error from "next/error";
16
17
export default function Preferences({ customize, page, pageNotFound }) {
18
const subpage = page[0] != null ? ` - ${capitalize(page[0])}` : "";
19
20
return (
21
<Customize value={customize}>
22
<Head title={`Store${subpage}`} />
23
<Layout>
24
<Header page={"store"} />
25
{pageNotFound ? <Error statusCode={404} /> : <Store page={page} />}
26
<Footer />
27
</Layout>
28
</Customize>
29
);
30
}
31
32
export async function getServerSideProps(context) {
33
let { page } = context.params;
34
if (page == null) {
35
page = [];
36
}
37
if (page.length > 0 && !StorePages.includes(page[0])) {
38
return await withCustomize({
39
context,
40
props: { pageNotFound: true, page },
41
});
42
}
43
44
return await withCustomize({ context, props: { page } });
45
}
46
47